package com.crm.dao.saling;

import com.crm.pojo.PlaningPay;
import com.crm.vo.PlaningPayClientContractUserInfoVO;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

/**
 * Created by dr5hx on 2018/8/10
 */
public interface PlaningPayDao extends CrudRepository<PlaningPay, Long> {
    @Query("from PlaningPay p where p.planingPayIsDel='否'")
    public List<PlaningPay> showPlaningPayList();

    @Query("update PlaningPay p set p.planingPayIsDel='是' where p.planingPayId=?1")
    @Modifying
    public void deletePlaningPayById(Long planingPayId);

    //ClientInfo client
    @Query("select new com.crm.vo.PlaningPayClientContractUserInfoVO(planingPay,purchase,userInfo) from PlaningPay planingPay,Purchase purchase,Userinfo userInfo where planingPay.fkPlaningPayPurchaseId=purchase.purid and planingPay.planingPayIsDel='否' and planingPay.fkPlaningPayEmpno=userInfo.uId")
    public List<PlaningPayClientContractUserInfoVO> getPlaningPayClientContractUserInfoVOList(Pageable pageable);

    @Query("select count(p) from PlaningPay  p where p.planingPayIsDel='否'")
    Long getPlaningPayListCount();
}
